package fnic.prehand.common;

import java.util.List;

import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;

public class AgentConfig { 
	 
	/**
     * singleton access
     */
    private static AgentConfig instance = new AgentConfig();
    public static AgentConfig getInstance()
    {
        return instance;
    }
    
    // 配置文件路径
    public static final String CONF_FILE = "es_agent.properties";
    
    //---------- common ----------
    //本代理节点标识
    private int agentId = 0;
	private boolean mujob_on = false; 
    private boolean netcenter_on = false;
    private boolean passitive_on = false;
    private boolean ap_on = false;


	public static final String KEY_AGENT_ID = "common.es_agent.id";   		
    public static final String SERVICE_MUJOB = "service.active.mujob";
    public static final String SERVICE_NC = "service.active.netcenter";
    public static final String SERVICE_PASSITIVE = "service.passitive";
    public static final String SERVICE_APMEASURE = "service.ap.measure";
    
    
    //------------- agent 作为服务端 ---------
    private int minThreadNumOfQueue = 10;
    private int maxThreadNumOfQueue = 100;
    public static final String KEY_MIN_THREAD_NUM = "server.threadpool.minThreads";
    public static final String KEY_MAX_THREAD_NUM = "server.threadpool.maxThreads";
    // 链路最大空闲时长，单位：秒
    private int idleTimeout = 60000;
    
    
    
    //--------------- request log ----------------- 
    private int retainDays = 90;
    private String requestLogTimezone = "GMT+8";
    private String requestLogDateFormat = "yyyy-MM-dd HH:mm:ss";
    public static final String KEY_REQ_LOG_RETAIN = "server.reqlog.retain";
    public static final String KEY_REQ_LOG_TIMEZONE = "server.reqlog.timeZone";
    public static final String KEY_REQ_LOG_DATE_FMT = "server.reqlog.dateFormat";
    
    //---------------- ElasticSearch----------------
    public static final String KEY_ESCLIENT_CLUSTERNAME = "client.es.clustername";
    public static final String KEY_ESCLIENT_WORKERNUM = "client.es.clientworkerNum";
    public static final String KEY_ESCLIENT_BULKSIZE = "client.es.clientBulkSize";
    
    public static final String KEY_ES_PSTV_INDEXNAME = "client.es.pstv.indexname";
    public static final String KEY_ES_PSTV_INDEXTYPE = "client.es.pstv.indextype";
    
    private String esClusterName;
    private int clientWorkNum;
//    private int clientRelaxPeriod;
    private int bulkSize;
    
	private String pesIndexName;
    private String pesIndexType;
    
 //---------------- DB----------------
    
    // DB地址与端口
//    private String ctrlDBIp = "192.168.28.100";
//	private short  ctrlDBPort = 8080;
//    private String skValidIp = "192.168.28.100";
//    private short  skValidPort = 8080;
//	private String pbAddrIp = "192.168.28.100";
//    private short  pbAddrPort = 8080;
//    public static final String KEY_Index_HTTP_IP = "client.ctrlSaveIndex.http.ip";
//    public static final String KEY_Index_HTTP_PORT = "client.ctrlSaveIndex.http.port";
//    public static final String KEY_SK_HTTP_IP = "client.validSessionKey.http.ip";
//    public static final String KEY_SK_HTTP_PORT = "client.validSessionKey.http.port";
//    public static final String KEY_PBADDR_HTTP_IP = "client.probeaddr.http.ip";
//    public static final String KEY_PBADDR_HTTP_PORT = "client.probeaddr.http.port";
    
    //---------------- sessionKey----------------
    private int sessionKeyFlg = 1;
	private int sessionKeySleepInterval = 2;
    private int sessionKeyMapSize = 500;
    private static final String SESSION_KEY_OPEN = "client.sessionKey.on";
    private static final String SESSION_KEY_SlEEP = "client.sessionKey.sleepInterval";
    private static final String SESSION_KEY_MAPSIZE = "client.sessionKey.mapsize";
    
    //----------------------probeAddress---------
    private int pbAddrMapSize = 100;
	private static final String PROBE_ADDR_MAPSIZE = "client.probeaddr.mapsize";
    
	
	//-------------------------redis--------------------
	/* Redis Related things */
//	private String  redisHost = "localhost";
//	private int     redisPort = 1234;
//	private String  redisKey = "A.MR";
//	private int     redisDB = 0;
	private String  redisMode = "list";
	private String  redisPsw = "";
	private int     redistimeout = 100;  //ms
	private int     redisthdnum = 1;
	private int     redisoncedealnum = 100;
	
	public static final String REDIS_MODE = "redis.mode";
	public static final String REDIS_PW = "redis.passwd";
	public static final String REDIS_TIMEOUT = "redis.timeout";
	public static final String REDIS_THREAD_NUM = "redis.thread.mum";
	public static final String REDIS_ONCEDEAL_NUM = "redis.once.deal.mum";

	private int     jedisMaxTotal = 1024;
	private int     jedisMaxIdle = 200;
	private int     jedismaxWaitMillis = 1000;
	private boolean jedistestOnBorrow = true;
	private boolean jedistestOnReturn = true;
	public static final String JEDIS_TOTAL = "jedis.pool.maxTotal";
	public static final String JEDIS_IDLE = "jedis.pool.maxIdle";
	public static final String JEDIS_WAITMILLIS = "jedis.pool.maxWaitMillis";
	public static final String JEDIS_TESTBRW = "jedis.pool.testOnBorrow";
	public static final String JEDIS_TESTRTN = "jedis.pool.testOnReturn";
	
	private String  predisHost = "192.168.48.197";
	private int     predisPort = 6379;
	private String  predisKey = "P:flow:ipv4";
	private List<String>  pfieldtypename ;
	private List<String>  pflowfieldname ;
	private List<String>  paugfieldname ;
	private int           paggr_interval = 30;
	private int           preadRedis_max = 4;
	private int           preadRedis_min = 2;
	
	//主动
//	public static final String REDIS_HOST = "redis.host";
//	public static final String REDIS_PORT = "redis.port";
//	public static final String REDIS_AR_KEY = "redis.ar.key";
//	public static final String REDIS_DB_NUM = "redis.db.num";


	//被动
	public static final String P_REDIS_HOST = "p.redis.host";
	public static final String P_REDIS_PORT = "p.redis.port";
	public static final String P_REDIS_KEY = "p.redis.key";
	public static final String P_REDIS_FIELD_TYPENAME = "p.redis.typename";
	public static final String P_REDIS_FLOW_NAME = "p.redis.flow.field";
	public static final String P_REDIS_AUG_NAME = "p.redis.augment.field";
	public static final String P_AGGRATE_INTERVAL = "p.aggrate.interval";
	public static final String P_REDIS_MAXSLEEP = "p.readredis.sleepmax";
	public static final String P_REDIS_MINSLEEP = "p.readredis.sleepmin";
	
    //-------------mujob ---------
    private int mujob_httpPort = 8083;
	private String mujob_logName = "./logs/request.log";
	private String mujob_IndexName;
    private String mujob_IndexType;

	private String  mujob_redisHost = "localhost";
	private int     mujob_redisPort = 1234;
	private int     mujob_redisDB = 0;
	private String  mujob_redisKey = "A.MR";

	private String mujob_ctrlIp = "192.168.28.100";
	private short  mujob_ctrlPort = 8080;
    private String mujob_skValidIp = "192.168.28.100";
    private short  mujob_skValidPort = 8080;
	private String mujob_pbAddrIp = "192.168.28.100";
    private short  mujob_pbAddrPort = 8080;
    

    public static final String MUJOB_HTTP_PORT = "mujob.http.port";
    public static final String MUJOB_LOG_FILENAME = "mujob.reqlog.filename";
    public static final String MUJOB_INDEXNAME = "mujob.es.indexname";
    public static final String MUJOB_INDEXTYPE = "mujob.es.indextype";
	
	public static final String MUJOB_REDIS_HOST = "mujob.redis.host";
	public static final String MUJOB_REDIS_PORT = "mujob.redis.port";
	public static final String MUJOB_REDIS_AR_KEY = "mujob.redis.ar.key";
	public static final String MUJOB_REDIS_DB_NUM = "mujob.redis.db.num";
    
    public static final String MUJOB_CTRL_IP = "mujob.ctrlSaveIndex.http.ip";
    public static final String MUJOB_CTRL_PORT = "mujob.ctrlSaveIndex.http.port";
    public static final String MUJOB_SK_HTTP_IP = "mujob.validSessionKey.http.ip";
    public static final String MUJOB_SK_HTTP_PORT = "mujob.validSessionKey.http.port";
    public static final String MUJOB_PBADDR_HTTP_IP = "mujob.probeaddr.http.ip";
    public static final String MUJOB_PBADDR_HTTP_PORT = "mujob.probeaddr.http.port";
    //-------------net center ---------

    private int nc_httpPort = 18083;
	private String nc_logName = "./logs/request.log";
	private String nc_IndexName;
    private String nc_IndexType;



	private String  nc_redisHost = "localhost";
	private int     nc_redisPort = 1234;
	private int     nc_redisDB = 0;
	private String  nc_redisKey = "A.MR";

	private String nc_ctrlIp = "192.168.28.100";
	private short  nc_ctrlPort = 8080;
    private String nc_skValidIp = "192.168.28.100";
    private short  nc_skValidPort = 8080;
	private String nc_pbAddrIp = "192.168.28.100";
    private short  nc_pbAddrPort = 8080;
    
    public static final String NC_HTTP_PORT = "nc.http.port";
    public static final String NC_LOG_FILENAME = "nc.reqlog.filename";
    public static final String NC_INDEXNAME = "nc.es.indexname";
    public static final String NC_INDEXTYPE = "nc.es.indextype";
    
	public static final String NC_REDIS_HOST = "nc.redis.host";
	public static final String NC_REDIS_PORT = "nc.redis.port";
	public static final String NC_REDIS_AR_KEY = "nc.redis.ar.key";
	public static final String NC_REDIS_DB_NUM = "nc.redis.db.num";
    
    public static final String NC_CTRL_IP = "nc.ctrlSaveIndex.http.ip";
    public static final String NC_CTRL_PORT = "nc.ctrlSaveIndex.http.port";
    public static final String NC_SK_HTTP_IP = "nc.validSessionKey.http.ip";
    public static final String NC_SK_HTTP_PORT = "nc.validSessionKey.http.port";
    public static final String NC_PBADDR_HTTP_IP = "nc.probeaddr.http.ip";
    public static final String NC_PBADDR_HTTP_PORT = "nc.probeaddr.http.port";
    
/*===================ap上报============================*/
    private  int ap_httpPort = 28083;
	private  String ap_logName = "./logs/request.log";
	private  String ap_indexName="mujob";
	private  String aptype_apinfo="apinfo";
	private  String aptype_stainfo="stainfo";

	private  String aptype_apinfo_his="apinfo_history";
	private  String aptype_stainfo_his="stainfo_history";
	
	private  String aptype_apflow="apflow";
	private  String aptype_staflow="staflow";
	private  String aptype_approperty="appro";
	private  String aptype_staproperty="stapro";
	
	private String apredisHost = "192.168.28.154";
	private int apredisPort = 6379;
	private String apflowKey = "apflow";
	private String staflowKey = "staflow";
	private String staloginKey = "login";
	private String stalogoutKey = "logout";		
	
	private static final String AP_HTTP_PORT = "ap.http.port";
    private static final String AP_LOG_FILENAME = "ap.reqlog.filename";
	private static final String AP_INDEX = "ap.index.name";
	private static final String AP_INFO_AP = "ap.type.apinfo";
	private static final String AP_INFO_STA = "ap.type.stainfo";
	private static final String AP_INFOHIS_AP = "ap.type.apinfo.his";
	private static final String AP_INFOHIS_STA = "ap.type.stainfo.his";
	private static final String AP_FLOW_AP = "ap.type.apflow";
	private static final String AP_FLOW_STA = "ap.type.staflow";
	private static final String AP_PROPERTY_AP = "ap.type.appro";
	private static final String AP_PROPERTY_STA = "ap.type.stapro";
	
	private static final String AP_REDISHOST = "ap.redis.host";
	private static final String AP_REDISPORT = "ap.redis.port";
	private static final String APFLOWKEY = "ap.redis.key.apflow";
	private static final String STAFLOWKEY = "ap.redis.key.staflow";
	private static final String STALOGINKEY = "ap.redis.key.stalogin";
	private static final String STALOGOUTKEY = "ap.redis.key.stalogout";
	
	/**
     * 加载Agent配置
     * @throws ConfigurationException cex
     */
    public void load() throws ConfigurationException
    {
        PropertiesConfiguration config = new PropertiesConfiguration(CONF_FILE);        
        agentId = Integer.parseInt((String) config.getProperty(KEY_AGENT_ID));
        mujob_on =  Boolean.valueOf((String)config.getProperty(SERVICE_MUJOB));
        netcenter_on =  Boolean.valueOf((String)config.getProperty(SERVICE_NC)); 
        passitive_on =  Boolean.valueOf((String)config.getProperty(SERVICE_PASSITIVE)); 
        ap_on =  Boolean.valueOf((String)config.getProperty(SERVICE_APMEASURE)); 

        minThreadNumOfQueue = Integer.parseInt((String) config.getProperty(KEY_MIN_THREAD_NUM));
        maxThreadNumOfQueue = Integer.parseInt((String) config.getProperty(KEY_MAX_THREAD_NUM));

        retainDays = Integer.parseInt((String) config.getProperty(KEY_REQ_LOG_RETAIN));
        requestLogTimezone = (String) config.getProperty(KEY_REQ_LOG_TIMEZONE);
        requestLogDateFormat = (String) config.getProperty(KEY_REQ_LOG_DATE_FMT);
        
        esClusterName = (String) config.getProperty(KEY_ESCLIENT_CLUSTERNAME);

        clientWorkNum = Integer.parseInt((String) config.getProperty(KEY_ESCLIENT_WORKERNUM));
//        clientRelaxPeriod = Integer.parseInt((String) config.getProperty(KEY_ESCLIENT_WORKRELAXPERIOD));
        bulkSize = Integer.parseInt((String) config.getProperty(KEY_ESCLIENT_BULKSIZE));
        pesIndexName = (String) config.getProperty(KEY_ES_PSTV_INDEXNAME);
        pesIndexType = (String) config.getProperty(KEY_ES_PSTV_INDEXTYPE);
        
//        ctrlDBIp = (String) config.getProperty(KEY_Index_HTTP_IP);
//        ctrlDBPort = Short.parseShort((String) config.getProperty(KEY_Index_HTTP_PORT));
//        skValidIp = (String) config.getProperty(KEY_SK_HTTP_IP);
//        skValidPort = Short.parseShort((String) config.getProperty(KEY_SK_HTTP_PORT));
//        pbAddrIp = (String) config.getProperty(KEY_PBADDR_HTTP_IP);
//        pbAddrPort = Short.parseShort((String) config.getProperty(KEY_PBADDR_HTTP_PORT));
        sessionKeyFlg = Integer.parseInt((String) config.getProperty(SESSION_KEY_OPEN));
        sessionKeySleepInterval = Integer.parseInt((String) config.getProperty(SESSION_KEY_SlEEP));
        sessionKeyMapSize = Integer.parseInt((String) config.getProperty(SESSION_KEY_MAPSIZE));
        
        redisMode = (String) config.getProperty(REDIS_MODE);
        redisPsw = (String) config.getProperty(REDIS_PW);
        redistimeout = Integer.parseInt((String) config.getProperty(REDIS_TIMEOUT));
        redisthdnum = Integer.parseInt((String) config.getProperty(REDIS_THREAD_NUM));
        redisoncedealnum = Integer.parseInt((String) config.getProperty(REDIS_ONCEDEAL_NUM));
        
    	jedisMaxTotal = Integer.parseInt((String) config.getProperty(JEDIS_TOTAL));
    	jedisMaxIdle = Integer.parseInt((String) config.getProperty(JEDIS_IDLE));
    	jedismaxWaitMillis = Integer.parseInt((String) config.getProperty(JEDIS_WAITMILLIS));
    	jedistestOnBorrow = Boolean.valueOf((String)config.getProperty(JEDIS_TESTBRW));
    	jedistestOnReturn = Boolean.valueOf((String)config.getProperty(JEDIS_TESTRTN));
        
        predisHost = (String) config.getProperty(P_REDIS_HOST);
        predisPort = Integer.parseInt((String) config.getProperty(P_REDIS_PORT));
        predisKey = (String) config.getProperty(P_REDIS_KEY);
        pfieldtypename = (List<String>) config.getProperty(P_REDIS_FIELD_TYPENAME);
        pflowfieldname =  (List<String>) config.getProperty(P_REDIS_FLOW_NAME);
        paugfieldname =   (List<String>) config.getProperty(P_REDIS_AUG_NAME);
        paggr_interval = Integer.parseInt((String) config.getProperty(P_AGGRATE_INTERVAL));
        preadRedis_min = Integer.parseInt((String) config.getProperty(P_REDIS_MINSLEEP));
        preadRedis_max = Integer.parseInt((String) config.getProperty(P_REDIS_MAXSLEEP));
        
        
        mujob_httpPort = Integer.parseInt((String) config.getProperty(MUJOB_HTTP_PORT));
        mujob_logName = (String) config.getProperty(MUJOB_LOG_FILENAME);
        mujob_IndexName = (String) config.getProperty(MUJOB_INDEXNAME);
        mujob_IndexType = (String) config.getProperty(MUJOB_INDEXTYPE);
        
        mujob_redisHost = (String) config.getProperty(MUJOB_REDIS_HOST);
        mujob_redisPort = Integer.parseInt((String) config.getProperty(MUJOB_REDIS_PORT));
        mujob_redisKey = (String) config.getProperty(MUJOB_REDIS_AR_KEY);
        mujob_redisDB = Integer.parseInt((String) config.getProperty(MUJOB_REDIS_DB_NUM));
        
        mujob_ctrlIp = (String) config.getProperty(MUJOB_CTRL_IP);
        mujob_ctrlPort = Short.parseShort((String) config.getProperty(MUJOB_CTRL_PORT));
        mujob_skValidIp = (String) config.getProperty(MUJOB_SK_HTTP_IP);
        mujob_skValidPort = Short.parseShort((String) config.getProperty(MUJOB_SK_HTTP_PORT));
        mujob_pbAddrIp = (String) config.getProperty(MUJOB_PBADDR_HTTP_IP);
        mujob_pbAddrPort = Short.parseShort((String) config.getProperty(MUJOB_PBADDR_HTTP_PORT));
        
        
        nc_httpPort = Integer.parseInt((String) config.getProperty(NC_HTTP_PORT));
        nc_logName = (String) config.getProperty(NC_LOG_FILENAME);
        nc_IndexName = (String) config.getProperty(NC_INDEXNAME);
        nc_IndexType = (String) config.getProperty(NC_INDEXTYPE);
        
        nc_redisHost = (String) config.getProperty(NC_REDIS_HOST);
        nc_redisPort = Integer.parseInt((String) config.getProperty(NC_REDIS_PORT));
        nc_redisKey = (String) config.getProperty(NC_REDIS_AR_KEY);
        nc_redisDB = Integer.parseInt((String) config.getProperty(NC_REDIS_DB_NUM));
        
        nc_ctrlIp = (String) config.getProperty(NC_CTRL_IP);
        nc_ctrlPort = Short.parseShort((String) config.getProperty(NC_CTRL_PORT));
        nc_skValidIp = (String) config.getProperty(NC_SK_HTTP_IP);
        nc_skValidPort = Short.parseShort((String) config.getProperty(NC_SK_HTTP_PORT));
        nc_pbAddrIp = (String) config.getProperty(NC_PBADDR_HTTP_IP);
        nc_pbAddrPort = Short.parseShort((String) config.getProperty(NC_PBADDR_HTTP_PORT));
        
        ap_httpPort = Integer.parseInt((String) config.getProperty(AP_HTTP_PORT));
        ap_logName = (String) config.getProperty(AP_LOG_FILENAME);
        ap_indexName = (String) config.getProperty(AP_INDEX);
        aptype_apinfo = (String) config.getProperty(AP_INFO_AP);
        aptype_stainfo = (String) config.getProperty(AP_INFO_STA);
    	aptype_apinfo_his = (String) config.getProperty(AP_INFOHIS_AP);
    	aptype_stainfo_his = (String) config.getProperty(AP_INFOHIS_STA);
        aptype_apflow = (String) config.getProperty(AP_FLOW_AP);
        aptype_staflow = (String) config.getProperty(AP_FLOW_STA);
        aptype_approperty = (String) config.getProperty(AP_PROPERTY_AP);
        aptype_staproperty = (String) config.getProperty(AP_PROPERTY_STA);
    	
    	apredisHost = (String) config.getProperty(AP_REDISHOST);
    	apredisPort = Integer.parseInt((String) config.getProperty(AP_REDISPORT));
        apflowKey = (String) config.getProperty(APFLOWKEY);
        staflowKey = (String) config.getProperty(STAFLOWKEY);
        staloginKey = (String) config.getProperty(STALOGINKEY);
        stalogoutKey = (String) config.getProperty(STALOGOUTKEY);
    }
    
    public int getAgentId()
    {
        return agentId;
    }
    public boolean isMujob_on() {
		return mujob_on;
	}
	public boolean isNetcenter_on() {
		return netcenter_on;
	}
	public boolean isPassitive_on() {
		return passitive_on;
	}
    public boolean isAp_on() {
		return ap_on;
	}
	
    public int getMinThreadNumOfQueue()
    {
        return minThreadNumOfQueue;
    }
    public int getMaxThreadNumOfQueue()
    {
        return maxThreadNumOfQueue;
    }
    public int getIdleTimeout()
    {
        return idleTimeout;
    }
    public int getRetainDays()
    {
        return retainDays;
    }
    public String getRequestLogTimezone()
    {
        return requestLogTimezone;
    }
    public String getRequestLogDateFormat()
    {
        return requestLogDateFormat;
    }


    public String getEsClusterName()
    {
        return esClusterName;
    }
    public int getclientWorkNum()
    {
        return clientWorkNum;
    }
    public int getclientBulkSize()
    {
        return bulkSize;
    }
    
    public String getPesIndexName() {
		return pesIndexName;
	}
	public String getPesIndexType() {
		return pesIndexType;
	}

    
    //------------sessionKey----------------------------
    public int getSessionKeyFlg() {
		return sessionKeyFlg;
	}
    public int getSessionKeySleepInterval() {
		return sessionKeySleepInterval;
	}

	public int getSessionKeyMapSize() {
		return sessionKeyMapSize;
	}
	
    public int getPbAddrMapSize() {
		return pbAddrMapSize;
	}

	public void setPbAddrMapSize(int pbAddrMapSize) {
		this.pbAddrMapSize = pbAddrMapSize;
	}
	
	//------------redis----------------------------
	public String getRedisMode() {
		return redisMode;
	}
	public String getRedisPsw() {
		return redisPsw;
	}
	public int getRedistimeout() {
		return redistimeout;
	}
	public int getRedisthdnum() {
		return redisthdnum;
	}
	public int getRedisoncedealnum() {
		return redisoncedealnum;
	}
	
	public int getJedisMaxTotal() {
		return jedisMaxTotal;
	}

	public int getJedisMaxIdle() {
		return jedisMaxIdle;
	}

	public int getJedismaxWaitMillis() {
		return jedismaxWaitMillis;
	}

	public boolean isJedistestOnBorrow() {
		return jedistestOnBorrow;
	}

	public boolean isJedistestOnReturn() {
		return jedistestOnReturn;
	}
	
	public String getPredisHost() {
		return predisHost;
	}
	public int getPredisPort() {
		return predisPort;
	}
	public String getPredisKey() {
		return predisKey;
	}
	public List<String> getPfieldtypename() {
		return pfieldtypename;
	}
	public List<String> getPflowfieldname() {
		return pflowfieldname;
	}
	public List<String> getPaugfieldname() {
		return paugfieldname;
	}
	public int getPaggr_interval() {
		return paggr_interval;
	}
	public int getPreadRedis_max() {
		return preadRedis_max;
	}
	public int getPreadRedis_min() {
		return preadRedis_min;
	}
	
	
    public int getMujob_httpPort() {
		return mujob_httpPort;
	}
	public String getMujob_logName() {
		return mujob_logName;
	}
	
    public String getMujob_IndexName() {
		return mujob_IndexName;
	}
	public String getMujob_IndexType() {
		return mujob_IndexType;
	}
	
	public String getMujob_redisHost() {
		return mujob_redisHost;
	}

	public int getMujob_redisPort() {
		return mujob_redisPort;
	}

	public int getMujob_redisDB() {
		return mujob_redisDB;
	}

	public String getMujob_redisKey() {
		return mujob_redisKey;
	}
    public String getMujob_ctrlIp() {
		return mujob_ctrlIp;
	}

	public short getMujob_ctrlPort() {
		return mujob_ctrlPort;
	}

	public String getMujob_skValidIp() {
		return mujob_skValidIp;
	}

	public short getMujob_skValidPort() {
		return mujob_skValidPort;
	}

	public String getMujob_pbAddrIp() {
		return mujob_pbAddrIp;
	}

	public short getMujob_pbAddrPort() {
		return mujob_pbAddrPort;
	}
	
	
	
	
    public int getNc_httpPort() {
		return nc_httpPort;
	}

	public String getNc_logName() {
		return nc_logName;
	}
    public String getNc_IndexName() {
		return nc_IndexName;
	}

	public String getNc_IndexType() {
		return nc_IndexType;
	}
	
	public String getNc_redisHost() {
		return nc_redisHost;
	}

	public int getNc_redisPort() {
		return nc_redisPort;
	}

	public int getNc_redisDB() {
		return nc_redisDB;
	}

	public String getNc_redisKey() {
		return nc_redisKey;
	}
	public String getNc_ctrlIp() {
		return nc_ctrlIp;
	}

	public short getNc_ctrlPort() {
		return nc_ctrlPort;
	}

	public String getNc_skValidIp() {
		return nc_skValidIp;
	}

	public short getNc_skValidPort() {
		return nc_skValidPort;
	}

	public int getAp_httpPort() {
		return ap_httpPort;
	}

	public String getAp_logName() {
		return ap_logName;
	}
	
	public String getNc_pbAddrIp() {
		return nc_pbAddrIp;
	}

	public short getNc_pbAddrPort() {
		return nc_pbAddrPort;
	}
	
	public String getAp_indexName() {
		return ap_indexName;
	}

	public String getAptype_apinfo() {
		return aptype_apinfo;
	}

	public String getAptype_stainfo() {
		return aptype_stainfo;
	}
	
	public String getAptype_apinfo_his() {
		return aptype_apinfo_his;
	}

	public String getAptype_stainfo_his() {
		return aptype_stainfo_his;
	}

	public String getAptype_apflow() {
		return aptype_apflow;
	}

	public String getAptype_staflow() {
		return aptype_staflow;
	}

	public String getAptype_approperty() {
		return aptype_approperty;
	}

	public String getAptype_staproperty() {
		return aptype_staproperty;
	}
	
	public String getApredisHost() {
		return apredisHost;
	}

	public int getApredisPort() {
		return apredisPort;
	}
	public String getApflowKey() {
		return apflowKey;
	}

	public String getStaflowKey() {
		return staflowKey;
	}

	public String getStaloginKey() {
		return staloginKey;
	}

	public String getStalogoutKey() {
		return stalogoutKey;
	}
    /**
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString()
    {
		StringBuilder builder = new StringBuilder();
		builder.append("AgentConfig [agentId=").append(agentId).append("]")
				.append("\n mujob_on               =").append(mujob_on               )
				.append("\n netcenter_on           =").append(netcenter_on           )
				.append("\n passitive_on           =").append(passitive_on           )
				.append("\n")
				.append("\n minThreadNumOfQueue    =").append(minThreadNumOfQueue    )
				.append("\n maxThreadNumOfQueue    =").append(maxThreadNumOfQueue    )
				.append("\n idleTimeout            =").append(idleTimeout            )
				.append("\n")
				.append("\n retainDays             =").append(retainDays             )
				.append("\n requestLogTimezone     =").append(requestLogTimezone     )
				.append("\n requestLogDateFormat   =").append(requestLogDateFormat   )
				.append("\n")
				.append("\n esClusterName          =").append(esClusterName          )
				.append("\n clientWorkNum          =").append(clientWorkNum          )
				.append("\n bulkSize               =").append(bulkSize               )
				.append("\n pesIndexName           =").append(pesIndexName           )
				.append("\n pesIndexType           =").append(pesIndexType           )
				.append("\n")
				.append("\n sessionKeyFlg          =").append(sessionKeyFlg          )
				.append("\n sessionKeySleepInterval=").append(sessionKeySleepInterval)
				.append("\n sessionKeyMapSize      =").append(sessionKeyMapSize      )
				.append("\n")
				.append("\n pbAddrMapSize          =").append(pbAddrMapSize          )
				.append("\n")
				.append("\n redisMode              =").append(redisMode              )
				.append("\n redisPsw               =").append(redisPsw               )
				.append("\n redistimeout           =").append(redistimeout           )
				.append("\n redisthdnum            =").append(redisthdnum            )
				.append("\n redisoncedealnum       =").append(redisoncedealnum       )
				.append("\n")
				.append("\n jedisMaxTotal          =").append(jedisMaxTotal          )
				.append("\n jedisMaxIdle           =").append(jedisMaxIdle           )
				.append("\n jedismaxWaitMillis     =").append(jedismaxWaitMillis     )
				.append("\n jedistestOnBorrow      =").append(jedistestOnBorrow      )
				.append("\n jedistestOnReturn      =").append(jedistestOnReturn      )
				.append("\n")
				.append("\n predisHost             =").append(predisHost             )
				.append("\n predisPort             =").append(predisPort             )
				.append("\n predisKey              =").append(predisKey              )
				.append("\n pfieldtypename         =").append(pfieldtypename         )
				.append("\n pflowfieldname         =").append(pflowfieldname         )
				.append("\n paugfieldname          =").append(paugfieldname          )
				.append("\n")
				.append("\n mujob_httpPort         =").append(mujob_httpPort         )
				.append("\n mujob_logName          =").append(mujob_logName          )
				.append("\n mujob_IndexName        =").append(mujob_IndexName        )
				.append("\n mujob_IndexType        =").append(mujob_IndexType        )
				.append("\n")
				.append("\n mujob_redisHost        =").append(mujob_redisHost        )
				.append("\n mujob_redisPort        =").append(mujob_redisPort        )
				.append("\n mujob_redisDB          =").append(mujob_redisDB          )
				.append("\n mujob_redisKey         =").append(mujob_redisKey         )
				.append("\n")
				.append("\n mujob_ctrlIp           =").append(mujob_ctrlIp           )
				.append("\n mujob_ctrlPort         =").append(mujob_ctrlPort         )
				.append("\n mujob_skValidIp        =").append(mujob_skValidIp        )
				.append("\n mujob_skValidPort      =").append(mujob_skValidPort      )
				.append("\n mujob_pbAddrIp         =").append(mujob_pbAddrIp         )
				.append("\n mujob_pbAddrPort       =").append(mujob_pbAddrPort       )
				.append("\n")
				.append("\n nc_httpPort            =").append(nc_httpPort            )
				.append("\n nc_logName             =").append(nc_logName             )
				.append("\n nc_IndexName           =").append(nc_IndexName           )
				.append("\n nc_IndexType           =").append(nc_IndexType           )
				.append("\n")
				.append("\n nc_redisHost           =").append(nc_redisHost           )
				.append("\n nc_redisPort           =").append(nc_redisPort           )
				.append("\n nc_redisDB             =").append(nc_redisDB             )
				.append("\n nc_redisKey            =").append(nc_redisKey            )
				.append("\n")
				.append("\n nc_ctrlIp              =").append(nc_ctrlIp              )
				.append("\n nc_ctrlPort            =").append(nc_ctrlPort            )
				.append("\n nc_skValidIp           =").append(nc_skValidIp           )
				.append("\n nc_skValidPort         =").append(nc_skValidPort         )
				.append("\n nc_pbAddrIp            =").append(nc_pbAddrIp            )
				.append("\n nc_pbAddrPort          =").append(nc_pbAddrPort          )
				.append("\n")
				.append("\n ap_indexName           =").append(ap_indexName           )
				.append("\n aptype_apinfo          =").append(aptype_apinfo          )
				.append("\n aptype_stainf          =").append(aptype_stainfo         )
				.append("\n aptype_apflow          =").append(aptype_apflow          )
				.append("\n aptype_staflow         =").append(aptype_staflow         )
				.append("\n aptype_approperty      =").append(aptype_approperty      )
				.append("\n aptype_staproperty     =").append(aptype_staproperty     )
				;
		return builder.toString();
    }
    
    public static void main(String[] args){
		// 加载配置
		try {
			AgentConfig.getInstance().load();
		} catch (ConfigurationException e) {
			System.out.println("load es_agent configuration failed: " + e.getMessage());
			return;
		}
		
		System.out.println(AgentConfig.getInstance().toString());
    }
}
